﻿@using Newtouch.Infrastructure
@{
    var EnableLinkToOR = SysConfigReader.String("EnableLinkToOR");
}
<link href="@SiteUrl.GetStaticResourceScriptUrl("~/Content/css/TemperatureChart.css", false)" rel="stylesheet" />
<script src="~/Content/js/utility.js"></script>
<style type="text/css">
    #tablBaseInfo {
        margin: 5px 0 0 3px;
    }

        #tablBaseInfo td {
            padding: 3px 5px;
        }
</style>
<style media="print">
    .PageNext {
        page-break-after: always;
    }
</style>
@*<table id="tablBaseInfo" class="form" style="width:750px;">
        <tr style="display:none;">
            <td class="formValue" colspan="4">日期：<label id="lblRq"></label></td>
        </tr>
        <tr>
            <td class="formValue">姓名：<label id="lblXm" class="lblXm"></label></td>
            <td class="formValue">病历号：<label id="lblBlh" class="lblBlh"></label></td>
            <td class="formValue" style="display:none;">住院号：<label id="lblZyh" class="lblZyh"></label></td>
            <td class="formValue">病区：<label id="lblBq" class="lblBq"></label></td>
        </tr>
        <tr>
            <td class="formValue">床位：<label id="lblCw" class="lblCw"></label></td>
            <td class="formValue">入院日期：<label id="lblRqrq" class="lblRqrq"></label></td>
            <td class="formValue" style="display:none">出区日期：<label id="lblCqrq" class="lblCqrq"></label></td>
        </tr>
    </table>*@
<div id="3cbill">
    <div class="drawingboard" id="board0">
        <table class="bottomtbl">
            <tr>
                <td>呼吸(次/分)</td>
            </tr>
            <tr><td></td></tr>
            <tr>
                <td>心率(次/分)</td>
            </tr>
            <tr>
                <td>血压(mmHg)</td>
            </tr>
            <tr>
                <td>血氧饱和度%</td>
            </tr>
            <tr>
                <td>氧流量(升/分)</td>
            </tr>
            <tr>
                <td>皮试</td>
            </tr>
            @*<tr>
            <td>大便次数</td>
        </tr>*@
            @*<tr>
        <td>总入量(ml)</td>
        <td>摄入量(ml)</td>
            </tr>
            <tr>
                <td>总出量(ml)</td>
                <td>小&nbsp;&nbsp;便(ml)</td>
            </tr>
            <tr>
                <td>引流量(ml)</td>
            </tr>*@
            @*<tr>
            <td>输入液体量(ml)</td>
        </tr>*@
            <tr>
                <td>体&nbsp;&nbsp;重(kg)</td>
            </tr>
            <tr>
                <td>身&nbsp;&nbsp;高(cm)</td>
            </tr>
            <tr>
                <td>过敏史</td>
            </tr>
            @*<tr>
                <td>疼痛评分</td>
            </tr>*@
        </table>
    </div>
</div>
<script>
    var billIndex = 0;//三测单分页标记
    var billpageks = [];
    var billpagejs = [];
    var $board = null
    //base
    var spc = 16;
    var sspace = 11;
    var sspacewidth = 14;
    var outerspace = 3; //体温单外部留白
    var xouterspace = 3;
    var bodyHeight = 800;   //整体的高度
    var origin;
    //calc
    var sjStartTop;
    var contentStartTop;
    var contentStartLeft;
    var ord = 0; //呼吸排序号
    //血压、脉搏、呼吸、体温
    var twArr = [42, 41, 40, 39, 38, 37, 36, 35, 34,33];
    var hxArr = [100,80, 70, 60, 50, 40, 30, 20, 10, 0];
    var mbArr = [180, 160, 140, 120, 100, 80, 60, 40, 20,0];
    var xyArr = [180, 160, 140, 120, 100, 80, 60, 40, 20,0];
    var wljwArr = [42, 41, 40, 39, 38, 37, 36, 35, 34, 33];

    var twColor = 'cblue';
    var hxColor = 'cblack';
    var mbColor = 'cred';
    var xyszColor = 'corange';
    var xyxzColor = 'corange';
    var wljwColor = 'cred';

    //体温单content下边框的top坐标
    var twLastTop;
    //体温单content右边框的left坐标
    var twLastLeft;

    var bottomtrCount = $('.bottomtbl tr').length;
    var bodyLastTop;

    var rqCellValueArr = new Array();
    var rqCellValueArrShow = new Array();
    var ryrq;
    var chineseryrq = "";
    var ztItem = [];
    //定位
    if (window.top == window.self) {
        $('#tablBaseInfo').css('marginLeft', 30);
    }

    function reLocation() {
        origin = { x: xouterspace, y: 0 + outerspace };
        //calc
        sjStartTop = origin.y + spc * 2;
        contentStartTop = origin.y + spc * 4;
        contentStartLeft = origin.x + sspacewidth * 6;   //6格  //但得多给点宽度

        //体温单content下边框的top坐标
        twLastTop = contentStartTop + sspace * 5 * (twArr.length - 1);

        bodyLastTop = twLastTop + spc * bottomtrCount;
    };

    function search(kssj, jssj, zyh) {
        tempData = null; //
        tempKssj = null;
        $('#tablBaseInfo td label').html('');
        if (!kssj || !jssj || !zyh) {
            $.modalAlert('请完善筛选条件', 'error');
            return;
        }
        billIndex = 1;
        $("#3cbill").empty();//清空三测单内容
        $.najax({
            url: "/NurseManage/InpatientVitalSigns/DrawData",
            data: { kssj: kssj, jssj: jssj, zyh: zyh, pagesize: 7 },
            loadingtext: "体温单数据请求中，请稍后...",
            asnyc: false,
            success: function (data) {
                //
                if (!(data && data.list && data.list.length)) {
                    //draw([]);
                    if (!(data && data.patInfo)) {
                        $.modalAlert('请选择住院号', 'warning');
                        return;
                    }
                    //return;
                }
                //填充基本信息表格
                //if (data && data.patInfo) {
                //    fillPatBaseInfo(data.patInfo);
                //    ryrq = data.patInfo.ryrq;
                //}
                $('#lblRq').html($.getDate({ date: kssj }) + " 至 " + $.getDate({ date: jssj }));
                //
                if (!(data && data.list && data.list.length)) {
                    data.list = [];
                }
                else {
                    ord = 0; //呼吸排序号
                    billpageks = [];
                    billpagejs = [];
                    billIndexData = [];
                }

                var printHasNext = true;
				while (printHasNext) {
					var billHtml = '';
                    billHtml += '<div style="text-align: center;"><table id="tablBaseInfo' + billIndex +'" class="form tablBaseInfo" style="width:750px;margin: auto;"> <tr style="display:none;"><td class="formValue" colspan="4">日期：<label id="lblRq"+billIndex+ class="lblRq"></label></td></tr>';
                    billHtml += '<tr><td class="formValue" colspan="3" style="text-align:center;"><h4>'+ '@(ViewBag.HospitalName)'+'</h2></td></tr>';
                    billHtml += '<tr><td class="formValue" colspan="3" style="text-align:center;">体温单</td></tr>';
                    billHtml += '<tr><td class="formValue">姓名：<label id="lblXm' + billIndex +'" class="lblXm"></label></td><td class="formValue">病历号：<label id="lblBlh"+billIndex+ class="lblBlh"></label></td><td class="formValue" style="display:none;">住院号：<label id="lblZyh"+billIndex+ class="lblZyh"></label></td><td class="formValue">病区：<label id="lblBq"+billIndex+ class="lblBq"></label></td></tr>';
                    billHtml += '<tr><td class="formValue">床位：<label id="lblCw' + billIndex +'" class="lblCw"></label></td><td class="formValue">入院日期：<label id="lblRqrq"+billIndex+ class="lblRqrq"></label></td><td class="formValue" style="display:none">出区日期：<label id="lblCqrq"+billIndex+ class="lblCqrq"></label></td></tr></table></div>';
                    billHtml += '<div style="border-bottom:1px solid black;width:1139px;"></div>'
					billHtml += '<div class="drawingboard" id="board' + billIndex + '" style="width:1139px;height:860px;">';
                    billHtml += '<table class="bottomtbl"><tr><td rowspan="2">呼吸(次/分)</td></tr><tr></tr><tr><td>心率(次/分)</td></tr>';

                    billHtml += '<tr><td>血压(mmHg)</td></tr><tr><td>血氧饱和度%</td></tr><tr><td>氧流量(升/分)</td></tr><tr><td>皮试</td></tr>';
                    //billHtml += '<tr><td>大便次数</td></tr><tr><td>总入量(ml)</td></tr><tr><td>总出量(ml)</td></tr>';
                    billHtml += '<tr><td>体&nbsp;&nbsp;重(kg)</td></tr>';
                    billHtml += '<tr><td>身&nbsp;&nbsp;高(cm)</td></tr><tr><td>过敏史</td></tr></table></div><div style="text-align:center;"><span>第 ' + billIndex+' 页</span></div>';

					billHtml += '  <div class="PageNext"></div>';

					$(billHtml).appendTo($("#3cbill"));
                    rqCellValueArr.splice(0, rqCellValueArr.length);
                    rqCellValueArrShow.splice(0, rqCellValueArrShow.length);
                    ztItem.splice(0, ztItem.length);

					//填充基本信息表格
					if (data && data.patInfo) {
						fillPatBaseInfo(data.patInfo);
						ryrq = data.patInfo.ryrq;
					}

                    var drawData = [];
                    var lastday = "";
                    var billIndexData = data.list.filter((f, p) => { return f.nowpage == billIndex });
                    for (var i = 0; i < billIndexData.length; i++) {
                        var item = billIndexData[i];
                        var dd = $.getDate({ date: item.rq });
                        
                        //时间改为从数据库获取
                        if (lastday != item.rq) {
                            rqCellValueArr.push(dd);
                            if (i == 0) {
                                rqCellValueArrShow.push(dd);
                            } else {
                                rqCellValueArrShow.push(item.showrq);
                            }
                            lastday = item.rq;
                        };
                        if (!billpageks[item.nowpage]) {
                            billpageks[item.nowpage] = dd; //记录当前页的开始时间
                        }

                        billpagejs[item.nowpage] = dd; //记录当前页的结束时间
                        if (item.brzt == '@((int)EnumHlbrzt.Ry)' || item.brzt == '@((int)EnumHlbrzt.Cy)' || item.brzt == '@((int)EnumHlbrzt.Zr)' || item.brzt == '@((int)EnumHlbrzt.Sw)'|| item.brzt == '@((int)EnumHlbrzt.Zc)'|| item.brzt == '@((int)EnumHlbrzt.ss)'|| item.brzt == '@((int)EnumHlbrzt.hs)') {
                            var ztshowstr = "";
                            if (!!item.brzt_hh) {
                                ztshowstr += item.brzt_hh + "时";
                            }
                            if (!!item.brzt_mi) {
                                ztshowstr += item.brzt_mi + "分";
                            }
                            if (ztshowstr != "") {
                                ztItem.push({ rq: $.getDate({ date: item.rq }), sj: item.sj, brzt: item.brzt, showzt: ztshowstr });
                            }

                            //else {
                            //    var rq = new Date(item.rq.substring(0, 10) + " " + item.sj + ":00"); //$.getTime({ date: data.patInfo.rqrq });
                            //    var chineserq = transToChineseHM(rq.getHours(), rq.getMinutes());
                            //    ztItem.push({ rq: $.getDate({ date: item.rq }), sj: item.sj, brzt: item.brzt, showzt: chineserq });
                            //}
                        }
                        @*else if (item.brzt == '@((int)EnumHlbrzt.Qj)') {
                            ztItem.push({ rq: $.getDate({ date: item.rq }), sj: item.sj, brzt: item.brzt, showzt: "请假" });
                        }*@
                        else if (item.brzt == '@((int)EnumHlbrzt.Jc)') {
                            ztItem.push({ rq: $.getDate({ date: item.rq }), sj: item.sj, brzt: item.brzt, showzt: "拒测" });
                        }
                        else if (item.brzt == '@((int)EnumHlbrzt.Fy)') {
                            ztItem.push({ rq: $.getDate({ date: item.rq }), sj: item.sj, brzt: item.brzt, showzt: "返院" });
                        }else if (item.brzt == '@((int)EnumHlbrzt.hs)') {
                            ztItem.push({ rq: $.getDate({ date: item.rq }), sj: item.sj, brzt: item.brzt, showzt: "返院" });
                        }

                        if (dd >= billpageks[item.nowpage] && dd <= billpagejs[item.nowpage]) {
                            drawData.push(item);
                        }
                    }
                    draw(drawData, billIndex);
                    if (!(data.list.find(p => p.nowpage == (billIndex + 1)))) {
                        printHasNext = false;
                    }

                    //重置下个开始时间
                    if (printHasNext) {
                        billIndex++;
                    }
                }
            }
        });
    }

    var tempData;    //使用setTimeout需要
    var tempKssj;
    function draw(data, index) {
        //先重置
        $board = $('#board' + index);
        $board.find('>*:not(table)').remove();
        $.each($('#board' + index + ' .bottomtbl tr'), function () {
            $(this).find('td:gt(0)').remove();
        });
        if (!rqCellValueArr || !rqCellValueArr.length) {
            //return;
        }
        //样式
        var docwd = $(document).width();
        var twdContentWidth = sspacewidth * 6 * (rqCellValueArr.length);
        twdContentWidth += sspacewidth * 9; //做日期列
        if ((docwd - twdContentWidth).toFixed(2) > 50) {
            if (window.top != window.self) {
                if (!rqCellValueArr || !rqCellValueArr.length) {

                }
                else {
                    xouterspace = parseInt((docwd - twdContentWidth).toFixed(2) / 2);  //可以多留点白
                }
            }
            else {
                xouterspace = 30;
            }
        }
        else {
            xouterspace = 3;    //default
        }
        //
        reLocation();
        twLastLeft = contentStartLeft + sspacewidth * 6 * (rqCellValueArr.length);
        //
        if (!(window.isIE() && window.isIElte8())) {
            //添加画布canvas
            $('#board' + index).append('<canvas id="drawCanvas' + index + '" width="' + twLastLeft + '" height="' + (twLastTop + 10) + '"></canvas> ');
            checkCanvasAble();
        }
        //画
        tempData = data;
        if (canvasAble) {
            startDraw();
            drawTwMemo();
        }
        else {
            setTimeout("$.loading(true, '体温单绘制中，请稍后...');", 25);
            setTimeout("startDraw();", 50);
        }
    }

    function startDraw() {
        var data = tempData;
        //
        drawTemplet(data);
        //
        if (canvasAble) {
            startDraw2();
        }
        else {
            setTimeout("startDraw2();", 50);
        }
    }

    function startDraw2() {
        var data = tempData;
        //
        drawDataPoint(data);
        //
        if (canvasAble) {
            startDraw3();
        }
        else {
            $.loading(true, '连线绘制中，可能耗时较长，请稍后...');
            setTimeout("startDraw3();", 50);
        }
    }

    function startDraw3() {
        var data = tempData;
        //
        drawDataLigature(data);
        //
        if (canvasAble) {
        }
        else {
            $.loading(false);
        }
    }

    //根据data重置画板 长高
    function drawTemplet(data) {
        //画板的长宽
        var totalwidth = $(window).width();
        var totalheight = bodyHeight;
        $board.css('width', totalwidth);
        $board.css('height', totalheight);
        //时间点上边框
        drawLine(origin.x, origin.y, twLastLeft - origin.x);
        //右侧加一点空白
        drawLine(twLastLeft, origin.y, xouterspace).css('visibility', 'hidden');
        //body上边框
        drawLine(origin.x, sjStartTop + spc, twLastLeft - origin.x);  //手术后天数
        drawLine(origin.x, sjStartTop, twLastLeft - origin.x);
        //body上边框
        drawLine(origin.x, sjStartTop - spc, twLastLeft - origin.x);
        //body左边框
        drawLine(origin.x, origin.y, bodyLastTop - origin.y, '', 'vline');
        //content左边框
        drawLine(contentStartLeft, origin.y, bodyLastTop - origin.y, '', 'vline');
        //content上边框
        drawLine(origin.x, contentStartTop, twLastLeft - origin.x);

        //竖向画线
        var rqCellCount = rqCellValueArr.length;
        for (var i = 0; i < rqCellCount; i++) {
            //右线
            var left = contentStartLeft + sspacewidth * 6 * (i + 1);
            if (i == rqCellCount - 1) {
                //最右侧画黑线
                drawLine(left, origin.y, twLastTop - origin.y, '', 'vline');
            } else {
                drawLine(left, origin.y, twLastTop - origin.y, 'cred', 'vline');
            }
            //底部table画竖线
            drawLine(left, twLastTop, bodyLastTop - twLastTop, '', 'vline');
            //中间5条时间点的线
            for (var j = 0; j < 5; j++) {
                left = contentStartLeft + sspacewidth * 6 * i + sspacewidth * (j + 1);
                if (j === 2) {
                    drawLine(left, sjStartTop + spc, twLastTop - sjStartTop + spc * 4, '', 'vline');
                }
                else {
                    drawLine(left, sjStartTop + spc, twLastTop - sjStartTop + spc, '', 'vline');
                }
            }
        }
        //横向画线
        for (var i = 0; i < (twArr.length - 1); i++) {
            var top = contentStartTop + sspace * 5 * (i + 1);
            //最后一条左起origin
            var left = i == (twArr.length - 1 - 1) ? origin.x : contentStartLeft;
            //最后一条颜色默认
            var colr = i == (twArr.length - 1 - 1) ? '' : 'c666';
            //最后一条不加粗
            var bold = i == (twArr.length - 1 - 1) ? '' : 'bold';
            drawLine(left, top, twLastLeft - left, colr, '', bold);
            //左侧血压、脉搏、呼吸、体温
            if (i == 0) {  //chl 42℃ 靠下方显示 不占用【体温】显示位置
                var ileft = left - ((contentStartLeft - origin.x) / 2) * 0 - 28;
                $div = $('<div style="position:absolute;text-align:center;left:' + ileft + 'px;top:' + (top - (sspace * 3.5) - 1) + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                    + twArr[i] + '℃</div>');
                $div.appendTo($board);
            }

            if (i < twArr.length - 1 - 1) {
                var ileft = left - ((contentStartLeft - origin.x) / 2) * 0 - 28;
                $div = $('<div style="position:absolute;text-align:center;left:' + ileft + 'px;top:' + (top - (sspace / 2) - 1) + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                    + twArr[i + 1] + '℃</div>');
                $div.appendTo($board);

                ileft = left - ((contentStartLeft - origin.x) / 2) * 1 - 28;
                $div = $('<div style="position:absolute;text-align:center;left:' + ileft + 'px;top:' + (top - (sspace / 2) - 1) + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                    + mbArr[i + 1] + '</div>');
                $div.appendTo($board);

            }
            //else if (i == twArr.length - 1 - 1) {
            //    var ileft = contentStartLeft - ((contentStartLeft - origin.x) / 2) * 0 - 28;
            //    $div = $('<div style="position:absolute;text-align:center;left:' + ileft + 'px;top:' + (top - (sspace * 4) - 1) + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
            //        + twArr[i + 1] + '℃</div>');
            //    $div.appendTo($board);
            //}
            //中间的4条温度的线（在这条线之上）
            for (var j = 0; j < 4; j++) {
                top = contentStartTop + sspace * 5 * i + sspace * (j + 1);
                drawLine(contentStartLeft, top, twLastLeft - contentStartLeft);
            }
        }
        //底部table画横线
        for (var i = 0; i < bottomtrCount-1; i++) {
            top = twLastTop + spc * (i + 2);
            var widthlength = twLastLeft - origin.x;
            if (i == bottomtrCount - 1-1) {
                widthlength++;  //使其看似闭合
            }
            drawLine(origin.x, top, widthlength);
        }
        //底部table  table的线和div难对其，所以用div画线
        $board.find('.bottomtbl').css('width', twLastLeft - origin.x)
            .css('left', origin.x).css('top', twLastTop).show();
        $board.find('.bottomtbl td').css('width', contentStartLeft - origin.x)
            .css('height', spc).css('line-height', spc + 'px');

        var thistdhtml = '<td style="width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;"></td>';
        for (var i = 0; i < rqCellValueArr.length; i++) {
            var thistd = "";
            var thistddown = "";
            var thistdxl = "";
            var rqData = $.jsonWhere(data, function (v) { return v.rq && $.getDate({ date: v.rq }) == rqCellValueArr[i] });
            var thistz = "";
            var thissg = "";
            var thisxybhd = 0;
            var thisxybhdpart2 = 0;
            var thisxyll = 0;
            var thisdbcs = "";
            var thisps = "";
            var thisttpf = "";    //疼痛评分
            var thiszrl = 0;    //总入量(ml)
            var thiszcl = 0;    //总出量(ml)
            //var thissrl = 0;    //摄入量(ml)
            //var thisxbl = 0;   //小便 计入总出量
            //var thisotl = 0;
            var thisgmyw = "";  //过敏药物
            var thisyll = 0;    //引流量
            var thissrytl = 0;    //输入液体量
            var thishx = 0;//呼吸
            var thissj = 0;
            var thisgxy = 0;//高血压
            var thisdxy = 0;//低血压
            var thisgxypart2 = 0;//高血压
            var thisdxypart2 = 0;//低血压
            var thisxl = "";//心率
            var thisxltwo = "";//心率2
            if (rqData.length < 1) {
                thistd += thistdhtml;
                thistd += thistdhtml;
                thistd += thistdhtml;
                thistd += thistdhtml;
                thistd += thistdhtml;
                thistd += thistdhtml;
                thistddown += thistdhtml;
                thistddown += thistdhtml;
                thistddown += thistdhtml;
                thistddown += thistdhtml;
                thistddown += thistdhtml;
                thistddown += thistdhtml;
            } else {
                //hss 修改于2019.08.22 呼吸显示bug修复
                for (var k = 1; k < 7; k++) {
                    var f = false;
                    var hx = "";
                    $.each(rqData, function (i, v) {
                        if (v.hx && parseInt(v.sj / 4+1) == k) {
                            f = true;
                            hx = v.hx;
                            ord++;
                        }
                    });
                    if (!f) {
                        thistd += thistdhtml; //呼吸上角标
                        thistddown += thistdhtml;//呼吸下角标
                    } else if (ord % 2 == 0 && ord != 0) {
                        thistddown += '<td style="width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + hx + '</td>';
                        thistd += thistdhtml;
                    }
                    else {
                        thistd += '<td style="width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + hx + '</td>';
                        thistddown += thistdhtml;
                    }
                }
            }

            for (var j = 0; j < rqData.length; j++) {

                if (rqData[j].brzt == '@((int)EnumHlbrzt.Wc)') {
                    thistz += "卧床";
                } else if (rqData[j].tz) {
                    thistz = rqData[j].tz.toString();
                }
                if (rqData[j].ps!=null) {
                    if (rqData[j].ps.toString() == "1") {
                        thisps = "(+)";
                    } else if (rqData[j].ps.toString() == "0") {
                        thisps = "(-)"
                    }
                }
                if (rqData[j].sg) {
                    thissg = rqData[j].sg.toString();
                }
                if (rqData[j].ttpf) {
                    thisttpf = rqData[j].ttpf;
                }
                if (rqData[j].xybhd) {
                    if (rqData[j].sj > 10) {
                        thisxybhdpart2 = rqData[j].xybhd;
                    }
                    else {
                        thisxybhd = rqData[j].xybhd;
                    }
                }
                if (rqData[j].xyll) {
                    thisxyll = rqData[j].xyll;
                }
                if (rqData[j].dbcs!=null) {
                    thisdbcs += rqData[j].dbcs;
                }
                if (rqData[j].dbcsbz) {
                    thisdbcs += rqData[j].dbcsbz;
                }
                //if (rqData[j].xbl) {
                //    thisxbl += rqData[j].xbl;
                //}
                //if (rqData[j].otl) {
                //    thisotl += rqData[j].otl;
                //}
                if (rqData[j].zrl) {
                    thiszrl += parseInt( rqData[j].zrl);
                }
                if (rqData[j].zcl) {
                    thiszcl += parseInt(rqData[j].zcl);
                }
                if (rqData[j].gmyw) {
                    thisgmyw += rqData[j].gmyw;
                }
                //if (rqData[j].syl) {
                //    thissrl += rqData[j].syl;
                //}
                //if (rqData[j].ysl) {
                //    thissrl += rqData[j].ysl;
                //}
                //if (rqData[j].sxl) {
                //    thissrl += rqData[j].sxl;
                //}
                //if (rqData[j].cys) {
                //    thisyll += rqData[j].cys;
                //}
                //if (rqData[j].skyll) {
                //    thisyll += rqData[j].skyll;
                //}
                //if (rqData[j].xyl) {
                //    thisyll += rqData[j].xyl;
                //}
                //if (rqData[j].wyl) {
                //    thisyll += rqData[j].wyl;
                //}
                //if (rqData[j].fxxq) {
                //    thisyll += rqData[j].fxxq;
                //}
                //if (rqData[j].qtsc) {
                //    thisyll += rqData[j].qtsc;
                //}
                if (rqData[j].yll) {
                    thisyll += parseInt(rqData[j].yll);
                }
                if (rqData[j].srytl) {
                    thissrytl += rqData[j].srytl;
                }
                if (rqData[j].xysz) {
                    if (rqData[j].sj > 10) {
                        thisgxypart2 = rqData[j].xysz;
                    }
                    else {
                        thisgxy = rqData[j].xysz;
                    }
                }
                if (rqData[j].xyxz) {
                    if (rqData[j].sj > 10) {
                        thisdxypart2 = rqData[j].xyxz;
                    }
                    else {
                        thisdxy = rqData[j].xyxz;
                    }
                }
                if (rqData[j].xl) {
                    if (rqData[j].sj > 10) {
                        thisxltwo = rqData[j].xl.toString();
                    }
                    else {
                        thisxl = rqData[j].xl.toString();
                    }
                }
            }
            $(thistd).appendTo($($board.find('.bottomtbl tr')[0]));
            $(thistddown).appendTo($($board.find('.bottomtbl tr')[1]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + thisxl + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" >' + thisxltwo + '</td>');
            $td.appendTo($($board.find('.bottomtbl tr')[2]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisgxy ? thisgxy + '/' : '') + (!!thisdxy ? thisdxy : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" >' + (!!thisgxypart2 ? thisgxypart2 + '/' : '') + (!!thisdxypart2 ? thisdxypart2 : '') + '</td>');
            $td.appendTo($($board.find('.bottomtbl tr')[3]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisxybhd ? thisxybhd : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" >' + (!!thisxybhdpart2 ? thisxybhdpart2 : '')+'</td>');
            $td.appendTo($($board.find('.bottomtbl tr')[4]));
            var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisxyll ? thisxyll : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
			$td.appendTo($($board.find('.bottomtbl tr')[5]));
			//var $td = $('<td colspan="6" style="width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisdbcs ? thisdbcs:'' ) + '</td>');
   //         $td.appendTo($($board.find('.bottomtbl tr')[6]));
            //var $td = $('<td colspan="6" style="width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thiszrl ? thiszrl : '') + '</td>');
            //var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thissrl ? thissrl : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            //$td.appendTo($($board.find('.bottomtbl tr')[7]));
            //var $td = $('<td colspan="6" style="width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thiszcl ? thiszcl : '') + '</td>');
           // $td.appendTo($($board.find('.bottomtbl tr')[8]));
            //var $td = $('<td colspan="6" style="width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisyll ? thisyll : '') + '</td>');
            //$td.appendTo($($board.find('.bottomtbl tr')[9]));
            if (thisps == "(-)") {
                var $td = $('<td colspan="6" style="width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;color:blue;">' + (!!thisps ? thisps : '') + '</td>');
                $td.appendTo($($board.find('.bottomtbl tr')[6]));
            } else if (thisps == "(+)") {
                var $td = $('<td colspan="6" style="width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;color:red;">' + (!!thisps ? thisps : '') + '</td>');
                $td.appendTo($($board.find('.bottomtbl tr')[6]));
            } else {
                var $td = $('<td colspan="6" style="width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisps ? thisps : '') + '</td>');
                $td.appendTo($($board.find('.bottomtbl tr')[6]));
            }
            //输入液体量
            //var $td = $('<td colspan="3" style="width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thissrytl ? thissrytl : '') + '</td><td colspan="3" style = "width:' + sspacewidth * 3 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;" ></td>');
            //$td.appendTo($($board.find('.bottomtbl tr')[10]));
            var $td = $('<td colspan="6" style="width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thistz ? thistz : '') + '</td>');
            $td.appendTo($($board.find('.bottomtbl tr')[7]));
            var $td = $('<td colspan="6" style="width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thissg ? thissg : '') + '</td>');
            $td.appendTo($($board.find('.bottomtbl tr')[8]));
            //var $td = $('<td colspan="6" style="width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisttpf ? thisttpf : '') + '</td>');
            //$td.appendTo($($board.find('.bottomtbl tr')[12]));
            var $td = $('<td colspan="6" class="memoStu" style="width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">' + (!!thisgmyw ? thisgmyw : '') + '</td>');
            $td.appendTo($($board.find('.bottomtbl tr')[9]));

        }

        //写日期，住院天数和时间th
        {
            var left = origin.x;
            var top = origin.y;
            var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top
                + 'px;width:' + (contentStartLeft - left) + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                + '日期' + '</div>');
            $div.appendTo($board);
            var top = origin.y + spc;
            var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top
                + 'px;width:' + (contentStartLeft - left) + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                + '住院天数' + '</div>');
            $div.appendTo($board);

            if ('@EnableLinkToOR' == "ON") {
                var top = origin.y + spc*2;
                var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top
                    + 'px;width:' + (contentStartLeft - left) + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                    + '手术后天数' + '</div>');
                $div.appendTo($board);
            }
            var left = origin.x;
            var top = origin.y + spc * 3;
            var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top
                + 'px;width:' + (contentStartLeft - left) + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                + '时间' + '</div>');
            $div.appendTo($board);
        }
        //写日期和时间点
        var ssrq;//记录手术日期
        for (var i = 0; i < rqCellValueArr.length; i++) {
            var left = contentStartLeft + i * sspacewidth * 6;
            var top = origin.y;
            var thisrq = rqCellValueArr[i];
            var rqcellData = $.jsonWhere(data, function (v) { return v.rq && $.getDate({ date: v.rq }) == rqCellValueArr[i] });
            if (!!rqcellData[0].sj && rqcellData[0].sj!=-1) {
                var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                    + rqCellValueArrShow[i] + '</div>');
                $div.appendTo($board);
                top = origin.y + spc;
                ryrq = ryrq.substring(0, 10) + " 00:00:00";
                var zyts = parseInt(Math.abs(Math.abs(new Date(ryrq) - new Date(thisrq))) / 1000 / 60 / 60 / 24) ;
                var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                    + zyts + '</div>');
                $div.appendTo($board);
                //手术后天数
                for (var ss = 0; ss < rqcellData.length; ss++) {
                        if (!!rqcellData[ss].brzt && rqcellData[ss].brzt == '@((int)EnumHlbrzt.ss)') {
                            ssrq = parseInt(Math.abs(Math.abs(new Date(rqcellData[ss].rq) - new Date(thisrq))) / 1000 / 60 / 60 / 24) +1;
                        }
                }
                var ssqr = "";
                if ((i+1) <= rqCellValueArr.length) {
                        var rqcellData0 = $.jsonWhere(data, function (v) { return v.rq && $.getDate({ date: v.rq }) == rqCellValueArr[i + 1] });
                        for (var rr = 0; rr < rqcellData0.length; rr++) {
                            if (!!rqcellData0[rr].brzt && rqcellData0[rr].brzt == '@((int)EnumHlbrzt.ss)') {
                                ssqr = "ssqr";
                            }
                        }
                    if (ssqr != "") {
                        top = origin.y + spc * 2;
                        var fontColor ='red';
                            var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;color:' + fontColor + ';">'
                                + '0' + '</div>');
                            $div.appendTo($board);
                        }
                    } 
                if (!!ssrq) {
                    top = origin.y + spc * 2;
                    var fontColor = ssrq >= 0 && ssrq < 15 ? 'red' : 'black';
                    var $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth * 6 + 'px;height:' + spc + 'px;line-height:' + spc + 'px;color:' + fontColor+';">'
                        + ssrq + '</div>');
                    $div.appendTo($board);
                    ssrq++;
                }
                for (var j = 0; j < 6; j++) {
                    left = contentStartLeft + i * sspacewidth * 6 + j * sspacewidth;
                    top = origin.y + spc * 3;

                    $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth + 'px;height:' + spc + 'px;line-height:' + spc + 'px;">'
                        + (4 * (j + 1) - 2) + '</div>');
                    $div.appendTo($board);
                }
            }
        }

        //左侧血压、脉搏、呼吸、体温 竖线+文字
        for (var i = 0; i < 2; i++) {
            var left = origin.x + ((contentStartLeft - origin.x) / 2) * i;
            var top = contentStartTop;
            drawLine(left, top, twLastTop - contentStartTop, '', 'vline');
            //文字
            var $div;
            $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + ((contentStartLeft - origin.x) / 2) + 'px;height:' + spc * 1 + 'px;line-height:' + spc + 'px;">'
                + (i == 0 ? '脉搏' : (i == 1 ? '体温' : '')) + '</div>');
            $div.appendTo($board);
            //说明放下方
            $div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + (twLastTop - sspace * 3) + 'px;width:' + ((contentStartLeft - origin.x) / 2) + 'px;height:' + spc * 1 + 'px;line-height:' + spc + 'px;">'
                + (i == 0 ? '(次/分)' : (i == 1 ? '(℃)' : '')) + '</div>');
            //$div = $('<div style="position:absolute;text-align:center;left:' + left + 'px;top:' + top + 'px;width:' + ((contentStartLeft - origin.x) / 2) + 'px;height:' + spc * 1 + 'px;line-height:' + spc + 'px;">'
            //    + (i == 0 ? '脉搏(次/分)' : (i == 1 ? '体温<br/>(℃)' : '')) + '</div>');
            //点在下方
            i == 0 ? drawDot(left + sspacewidth * 1.2, twLastTop - sspace, mbColor)
                : (i == 1 ? drawX(left + sspacewidth * 1.8, twLastTop - sspace, twColor)
                    : '');
            //i == 0 ? drawDot(left + sspacewidth * 1.2, top + sspace * 3, mbColor)
            //    : (i == 1 ? drawX(left + sspacewidth * 1.8, top + sspace * 3, twColor)
            //        : '');
            $div.appendTo($board);
        }
    }

    //画点
    function drawDataPoint(data) {
        //画点
        for (var i = 0; i < data.length; i++) {
            if (data[i].rq && data[i].sj && (data[i].sj % 2 == 0 || data[i].sj % 2 == 1)) {
                drawTwPoint(data[i]);
                drawMbPoint(data[i]);
                drawWljwPoint(data[i]);
                //drawHxPoint(data[i]);
                //drawXyPoint(data[i]);
            }
        }
    }

    //画连线
    function drawDataLigature(data) {
        //画连线
        var tempArr;
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.twLocation || v.brzt== '@((int)EnumHlbrzt.Qj)'||v.brzt== '@((int)EnumHlbrzt.Jc)'||v.brzt== '@((int)EnumHlbrzt.Fy)'})).length - 1; i++)
        //for (var i = 0; i < (tempArr = data).length - 1; i++)
        {
            if (tempArr[i].twLocation && tempArr[i + 1].twLocation) {
                //if (tempArr[i].rq && ($.getDate({ date: tempArr[i].rq }) == $.getDate({ date: tempArr[i + 1].rq, ute: true })
                //    || $.getDate({ date: $.dateAdd($.strToDate($.getDate({ date: tempArr[i].rq })), 'd', 1) }) == $.getDate({ date: tempArr[i + 1].rq, ute: true }))) {
                    //间隔超过1天不画连线
                    if (tempArr[i + 1].brzt != '@((int)EnumHlbrzt.Jc)' && tempArr[i + 1].brzt != '@((int)EnumHlbrzt.Fy)') {
                        drawLigature(tempArr[i].twLocation, tempArr[i + 1].twLocation, twColor);
                    }
                //}
            }
        }
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.hxLocation || v.brzt== '@((int)EnumHlbrzt.Qj)'||v.brzt== '@((int)EnumHlbrzt.Jc)'||v.brzt== '@((int)EnumHlbrzt.Fy)'})).length - 1; i++)
        //for (var i = 0; i < (tempArr = data).length - 1; i++)
        {
            if (tempArr[i].hxLocation && tempArr[i + 1].hxLocation) {
                //if (tempArr[i].rq && ($.getDate({ date: tempArr[i].rq }) == $.getDate({ date: tempArr[i + 1].rq, ute: true })
                //    || $.getDate({ date: $.dateAdd($.strToDate($.getDate({ date: tempArr[i].rq })), 'd', 1) }) == $.getDate({ date: tempArr[i + 1].rq, ute: true }))) {
                    //间隔超过1天不画连线
                    if (tempArr[i+1].brzt != '@((int)EnumHlbrzt.Jc)'&& tempArr[i+1].brzt != '@((int)EnumHlbrzt.Fy)') {
                        drawLigature(tempArr[i].hxLocation, tempArr[i + 1].hxLocation, hxColor);
                    }
                //}
            }
        }
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.mbLocation|| v.brzt== '@((int)EnumHlbrzt.Qj)'||v.brzt== '@((int)EnumHlbrzt.Jc)'||v.brzt== '@((int)EnumHlbrzt.Fy)' })).length - 1; i++)
        //for (var i = 0; i < (tempArr = data).length - 1; i++)
        {
            if (tempArr[i].mbLocation && tempArr[i + 1].mbLocation) {
                //if (tempArr[i].rq && ($.getDate({ date: tempArr[i].rq }) == $.getDate({ date: tempArr[i + 1].rq, ute: true })
                //    || $.getDate({ date: $.dateAdd($.strToDate($.getDate({ date: tempArr[i].rq })), 'd', 1) }) == $.getDate({ date: tempArr[i + 1].rq, ute: true }))) {
                    //间隔超过1天不画连线
                    if (tempArr[i+1].brzt != '@((int)EnumHlbrzt.Jc)'&& tempArr[i+1].brzt != '@((int)EnumHlbrzt.Fy)') {
                        drawLigature(tempArr[i].mbLocation, tempArr[i + 1].mbLocation, mbColor);
                    }
                //}
            }
        }
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.xyszLocation })).length - 1; i++) {
            if (tempArr[i].xyszLocation && tempArr[i + 1].xyszLocation) {
                if (tempArr[i].rq && ($.getDate({ date: tempArr[i].rq }) == $.getDate({ date: tempArr[i + 1].rq, ute: true })
                    || $.getDate({ date: $.dateAdd($.strToDate($.getDate({ date: tempArr[i].rq })), 'd', 1) }) == $.getDate({ date: tempArr[i + 1].rq, ute: true }))) {
                    //间隔超过1天不画连线
                    drawLigature(tempArr[i].xyszLocation, tempArr[i + 1].xyszLocation, xyszColor);
                }
            }
        }
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.xyxzLocation })).length - 1; i++) {
            if (tempArr[i].xyxzLocation && tempArr[i + 1].xyxzLocation) {
                if (tempArr[i].rq && ($.getDate({ date: tempArr[i].rq }) == $.getDate({ date: tempArr[i + 1].rq, ute: true })
                    || $.getDate({ date: $.dateAdd($.strToDate($.getDate({ date: tempArr[i].rq })), 'd', 1) }) == $.getDate({ date: tempArr[i + 1].rq, ute: true }))) {
                    //间隔超过1天不画连线
                    drawLigature(tempArr[i].xyxzLocation, tempArr[i + 1].xyxzLocation, xyxzColor);
                }
            }
        }
        //物理降温和体温连线
        for (var i = 0; i < (tempArr = $.jsonWhere(data, function (v) { return v.twLocation })).length; i++) {
            if (tempArr[i].twLocation && tempArr[i].wljwLocation) {
                drawLigature(tempArr[i].twLocation, tempArr[i].wljwLocation, 'cred', 'dotline');//虚线连接
            }
        }
    }
    //chl 添加护理说明 页面说明添加 入院 出院 转院 死亡 42°线 定格显示  其他 35°线定格显示
    function drawTwMemo() {
        if (ztItem.length > 0) {
            for (var i = 0; i < ztItem.length; i++) {
                idx = getIndexOfRq(ztItem[i].rq);
                var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * parseInt(ztItem[i].sj / 4);
                var top = contentStartTop + 2 * sspace;
                var brztms = "";
                if (ztItem[i].brzt == '@((int)EnumHlbrzt.Ry)') {
                    ztItem[i].tw = 42;
                    brztms = "入院〡" + ztItem[i].showzt;
                }
                else if (ztItem[i].brzt == '@((int)EnumHlbrzt.Cy)') {
                    ztItem[i].tw = 42;
                    brztms = "出院〡" + ztItem[i].showzt;
                }
                else if (ztItem[i].brzt == '@((int)EnumHlbrzt.Sw)') {
                    ztItem[i].tw = 42;
                    brztms = "死亡〡" + ztItem[i].showzt;
                }
                else if (ztItem[i].brzt == '@((int)EnumHlbrzt.Zr)') {
                    ztItem[i].tw = 42;
                    brztms = "转入〡" + ztItem[i].showzt;
                }
                else if (ztItem[i].brzt == '@((int)EnumHlbrzt.Zc)') {
                    ztItem[i].tw = 42;
                    brztms = "转出〡" + ztItem[i].showzt;
                }
                 else if (ztItem[i].brzt == '@((int)EnumHlbrzt.ss)') {
                    ztItem[i].tw = 42;
                    brztms = "手术〡" + ztItem[i].showzt;
                }else if (ztItem[i].brzt == '@((int)EnumHlbrzt.hs)') {
                    ztItem[i].tw = 42;
                    brztms = "回室〡" + ztItem[i].showzt;
                }
                if (ztItem[i].brzt == '@((int)EnumHlbrzt.Ry)' || ztItem[i].brzt == '@((int)EnumHlbrzt.Cy)' || ztItem[i].brzt == '@((int)EnumHlbrzt.Sw)' || ztItem[i].brzt == '@((int)EnumHlbrzt.Zr)'|| ztItem[i].brzt == '@((int)EnumHlbrzt.Zc)'||ztItem[i].brzt == '@((int)EnumHlbrzt.ss)'||ztItem[i].brzt == '@((int)EnumHlbrzt.hs)') {
                    $.each(brztms.split(''), function () {
                        var $div = $('<div class="memoStu" style="position:absolute;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth + 'px;height:' + (spc-2) + 'px;line-height:' + spc + 'px;">'
                            + this + '</div>');
                        $div.appendTo($board);
                        top += (twArr[0] - ztItem[i].tw + 0.2).toFixed(2) * 5 * sspace;
                    });
                }
                else {
                    ztItem[i].tw = 35;
                    $.each(ztItem[i].showzt.split(''), function () {
                        top = contentStartTop+(twArr[0] - ztItem[i].tw).toFixed(2) * 5 * sspace;
                        var $div = $('<div class="memoStu" style="position:absolute;left:' + left + 'px;top:' + top + 'px;width:' + sspacewidth + 'px;height:' + spc * 1 + 'px;line-height:' + spc + 'px;">'
                            + this + '</div>');
                        $div.appendTo($board);
                        ztItem[i].tw -= 0.2;
                    });
                }
            }
        }
    }
    //画体温点
    function drawTwPoint(item) {
        if (item.tw) {
            var idx = getIndexOfRq(item.rq);
            if (idx < 0) {
                return;
            }
            var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * parseInt(item.sj / 4);
            var top = contentStartTop;
            if (item.tw > twArr[0]) {
                top = contentStartTop;
            }
            else if (item.tw < twArr[twArr.length - 1]) {
                top = twLastTop;
            }
            else {
                //*5是因为每1度占5格 .toFixed(2)是js减法bug
                top += (twArr[0] - item.tw).toFixed(2) * 5 * sspace;
            }
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(twArr, function (v) { return v == item.tw }).length == 1
                && item.tw != twArr[0] && item.tw != twArr[twArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.twLocation = { x: left, y: top };
            drawX(left, top, twColor, item.tw);
            //伪造title
            drawFalsifyTitle(left, top, item.tw);
        }
    }

    //画脉搏点
    function drawMbPoint(item) {
        if (item.mb) {
            var idx = getIndexOfRq(item.rq);
            if (idx < 0) {
                return;
            }
            var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * parseInt(item.sj / 4);
            var top = contentStartTop;
            if (item.mb > mbArr[0]) {
                top = contentStartTop;
            }
            else if (item.mb < mbArr[mbArr.length - 1]) {
                top = twLastTop;
            }
            else {
                //*5是因为每20占5格 即每4占一格 .toFixed(2)是js减法bug
                top += ((mbArr[0] - item.mb).toFixed(2) / 4).toFixed(2) * sspace;
            }
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(mbArr, function (v) { return v == item.mb }).length == 1
                && item.mb != mbArr[0] && item.mb != mbArr[mbArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.mbLocation = { x: left, y: top };
            if (item.twLocation != null && item.twLocation != null && item.twLocation != undefined && item.twLocation != undefined) {
                if (item.twLocation.x == left && item.twLocation.y == top) {
                    drawcircleX(left, top, mbColor)
                    //伪造title
                    drawFalsifyTitle(left, top, item.tw + "，" + item.mb);
                }
                else {
                    drawDot(left, top, mbColor, item.mb);
                    //伪造title
                    drawFalsifyTitle(left, top, item.mb);
                }
            }
        }
    }

    //画呼吸点
    function drawHxPoint(item) {
        if (item.hx) {
            var idx = getIndexOfRq(item.rq);
            if (idx < 0) {
                return;
            }
            var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * parseInt(item.sj / 4);
            var top = contentStartTop + sspacewidth * 32;
            //if (item.hx > hxArr[0]) {
            //    top = contentStartTop;
            //}
            //else if (item.hx < hxArr[hxArr.length - 1]) {
            //    top = twLastTop;
            //}
            //else {
            //    //*5是因为每10占5格 即每2占一格 .toFixed(2)是js减法bug
            //    top += ((hxArr[0] - item.hx).toFixed(2) / 2).toFixed(2) * sspace;
            //}
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(hxArr, function (v) { return v == item.hx }).length == 1
                && item.hx != hxArr[0] && item.hx != hxArr[hxArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.hxLocation = { x: left, y: top };
            drawSquare(left, top, hxColor, item.hx);
            //伪造title
            drawFalsifyTitle(left, top, item.hx);
        }
    }

    //画血压点
    function drawXyPoint(item) {
        var idx = getIndexOfRq(item.rq);
        if (idx < 0) {
            return;
        }
        if (item.xysz) {
            var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * parseInt(item.sj / 4);
            var top = contentStartTop;
            if (item.xysz > xyArr[0]) {
                top = contentStartTop;
            }
            else if (item.xysz < xyArr[xyArr.length - 1]) {
                top = twLastTop;
            }
            else {
                //*5是因为每20占5格 即每4占一格 .toFixed(2)是js减法bug
                top += ((xyArr[0] - item.xysz).toFixed(2) / 4).toFixed(2) * sspace;
            }
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(xyArr, function (v) { return v == item.xysz }).length == 1
                && item.xysz != xyArr[0] && item.xysz != xyArr[xyArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.xyszLocation = { x: left, y: top };
            drawUparrow(left, top, xyszColor, item.xysz);
            //伪造title
            drawFalsifyTitle(left, top, item.xysz);
        }
        if (item.xyxz) {
            var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * parseInt(item.sj / 4);
            var top = contentStartTop;
            if (item.xyxz > xyArr[0]) {
                top = contentStartTop;
            }
            else if (item.xyxz < xyArr[xyArr.length - 1]) {
                top = twLastTop;
            }
            else {
                //*5是因为每20占5格 即每4占一格 .toFixed(2)是js减法bug
                top += ((xyArr[0] - item.xyxz).toFixed(2) / 4).toFixed(2) * sspace;
            }
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(xyArr, function (v) { return v == item.xyxz }).length == 1
                && item.xyxz != xyArr[0] && item.xyxz != xyArr[xyArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.xyxzLocation = { x: left, y: top };
            drawDownarrow(left, top, xyxzColor, item.xyxz);
            //伪造title
            drawFalsifyTitle(left, top, item.xyxz);
        }
    }

    //画物理降温
    function drawWljwPoint(item) {
        if (item.wljw) {
            var idx = getIndexOfRq(item.rq);
            if (idx < 0) {
                return;
            }
            var left = contentStartLeft + (sspacewidth * 6) * idx + sspacewidth * parseInt(item.sj / 4);
            var top = contentStartTop;
            if (item.wljw > wljwArr[0]) {
                top = contentStartTop;
            }
            else if (item.wljw < wljwArr[wljwArr.length - 1]) {
                top = twLastTop;
            }
            else {
                //*5是因为每1度占5格 .toFixed(2)是js减法bug
                top += (wljwArr[0] - item.wljw).toFixed(2) * 5 * sspace;
            }
            //让其居这个时间点 居中
            left += sspacewidth / 2;
            if ($.jsonWhere(wljwArr, function (v) { return v == item.wljw }).length == 1
                && item.wljw != wljwArr[0] && item.wljw != wljwArr[wljwArr.length - 1]) {
                top = top + 0.5;    //正点呈现特殊，因为线高度2px
            }
            item.wljwLocation = { x: left, y: top };
            drawRound(left, top, wljwColor, item.wljw);
            //伪造title
            drawFalsifyTitle(left, top, item.wljw);
        }
    }

    //type默认横线，传递false画竖线
    function drawLine(left, top, length, colorClass, type, bold, zIndex) {
        var html = '<div style="position:absolute;left:' + left + 'px;top:' + top + 'px;';
        html += (type === 'vline' ? 'height' : 'width') + ":" + length + "px;";
        if (zIndex) {
            html += 'z-index:' + zIndex + ';';
        }
        html += '"';
        html += ' class="';
        //默认横线
        var lineClass = (type === 'vline' ? 'vline' : 'line');
        lineClass = bold === 'bold' ? lineClass + "bold" : lineClass;
        html += ' ' + lineClass;
        //颜色默认#999
        html += ' ' + (!!colorClass ? colorClass : 'c999');
        html += '"';
        html += '>';
        html += '</div>';
        var $html = $(html);
        $html.appendTo($board);
        return $html;
    }

    //以(left, top)为中心画一个点
    function drawDot(left, top, colorClass) {
        //考虑border呈现问题
        left = left - 3;    //3为border的宽度
        top = top - 3;
        var html = '<div style="position:absolute;left:' + left + 'px;top:' + top + 'px;';
        html += '"';
        html += ' class="dot';
        //颜色默认#999
        html += ' ' + (!!colorClass ? colorClass : 'c999');
        html += '"';
        html += '>';
        html += '</div>';
        var $html = $(html);
        $html.appendTo($board);
        return $html;
    }

    //以(left, top)为中心画一个X
    function drawX(left, top, colorClass) {
        if (canvasdrawX(left, top, colorClass)) {
            return;
        }
        //left - 1是因为length 2
        drawLine(left - 0.5 - 1, top - 0.5, 2, colorClass);
        drawLine(left - 1.5 - 1, top - 1.5, 2, colorClass);
        drawLine(left - 2.5 - 1, top - 2.5, 2, colorClass);
        drawLine(left + 0.5 - 1, top + 0.5, 2, colorClass);
        drawLine(left + 1.5 - 1, top + 1.5, 2, colorClass);
        drawLine(left + 2.5 - 1, top + 2.5, 2, colorClass);
        //
        drawLine(left + 0.5 - 1, top - 0.5, 2, colorClass);
        drawLine(left + 1.5 - 1, top - 1.5, 2, colorClass);
        drawLine(left + 2.5 - 1, top - 2.5, 2, colorClass);
        drawLine(left - 0.5 - 1, top + 0.5, 2, colorClass);
        drawLine(left - 1.5 - 1, top + 1.5, 2, colorClass);
        drawLine(left - 2.5 - 1, top + 2.5, 2, colorClass);
    }

    //以(left, top)为中心画一个Square
    function drawSquare(left, top, colorClass) {
        if (canvasdrawSquare(left, top, colorClass)) {
            return;
        }
        drawLine(left - 2.5, top - 2.5, 6, colorClass);
        drawLine(left - 2.5, top + 2.5, 6, colorClass);
        drawLine(left - 2.5, top - 2.5, 6, colorClass, 'vline');
        drawLine(left + 2.5, top - 2.5, 6, colorClass, 'vline');
    }

    //以(left, top)为中心画一个上箭头
    function drawUparrow(left, top, colorClass) {
        if (canvasdrawUparrow(left, top, colorClass)) {
            return;
        }
        top += 2;   //使箭头在线上
        //left - 1是因为length 2
        drawLine(left - 1, top - 2, 2, colorClass);
        //
        drawLine(left + 1 - 1, top - 1, 2, colorClass);
        drawLine(left + 2 - 1, top, 2, colorClass);
        drawLine(left + 3 - 1, top + 1, 2, colorClass);
        drawLine(left + 4 - 1, top + 2, 2, colorClass);
        //
        drawLine(left - 1 - 1, top - 1, 2, colorClass);
        drawLine(left - 2 - 1, top, 2, colorClass);
        drawLine(left - 3 - 1, top + 1, 2, colorClass);
        drawLine(left - 4 - 1, top + 2, 2, colorClass);
    }

    //以(left, top)为中心画一个下箭头
    function drawDownarrow(left, top, colorClass) {
        if (canvasdrawDownarrow(left, top, colorClass)) {
            return;
        }
        top -= 2;   //使箭头在线上
        //left - 1是因为length 2
        drawLine(left - 1, top + 2, 2, colorClass);
        //
        drawLine(left + 1 - 1, top + 1, 2, colorClass);
        drawLine(left + 2 - 1, top, 2, colorClass);
        drawLine(left + 3 - 1, top - 1, 2, colorClass);
        drawLine(left + 4 - 1, top - 2, 2, colorClass);
        //
        drawLine(left - 1 - 1, top + 1, 2, colorClass);
        drawLine(left - 2 - 1, top, 2, colorClass);
        drawLine(left - 3 - 1, top - 1, 2, colorClass);
        drawLine(left - 4 - 1, top - 2, 2, colorClass);
    }

    //以(left, top)为中心画一个空心圆
    function drawRound(left, top, colorClass) {
        //考虑border呈现问题
        left = left - 3;    //3为border的宽度
        top = top - 3;
        var html = '<div style="position:absolute;left:' + left + 'px;top:' + top + 'px;';
        html += '"';
        html += ' class="round';
        //颜色默认#999
        html += ' ' + (!!colorClass ? colorClass : 'c999');
        html += '"';
        html += '>';
        html += '</div>';
        var $html = $(html);
        $html.appendTo($board);
        return $html;
    }
    //以(left, top)为中心画一个空心圆X
    function drawcircleX(left, top, colorClass) {
        //考虑border呈现问题
        left = left - 3;    //3为border的宽度
        top = top - 3;
        var html = '<div style="position:absolute;left:' + left + 'px;top:' + top + 'px;';
        html += '"';
        html += ' class="circleX';
        //颜色默认#999
        //html += ' ' + (!!colorClass ? colorClass : 'c999');
        html += '"';
        html += '>';
        html += '</div>';
        var $html = $(html);
        $html.appendTo($board);
        return $html;
    }


    //两点画连线 p2.x 比 p1.x大
    function drawLigature(p1, p2, colorClass, type) {//2021-2-5 增加type参数 dotline为虚线
        if (canvasdrawLigature(p1, p2, colorClass, type)) {
            return;
        }
        //x x之间多少个像素
        var xDifference = parseInt(p2.x - p1.x);
        //要画xDifference个像素点
        for (var i = 0; i < xDifference; i++) {
            var left = p1.x + i;
            var dwspace = ((p2.y - p1.y) / xDifference);
            var pointCount = dwspace % 1 == 0 ? Math.abs(parseInt(dwspace)) : (Math.abs(parseInt(dwspace)) + 1);
            if (pointCount == 0) {
                //这是横线
                var top = p1.y;
                if (type == 'dotline') {//虚线
                    drawLine(left, top, 1, colorClass, 'dotline', '', 2);
                } else {
                    drawLine(left, top, 1, colorClass, '', '', 2);
                }
            }
            else if (pointCount == 1) {
                var top = p1.y + dwspace * i;
                if (type == 'dotline') {//虚线
                    drawLine(left, top, 1, colorClass, 'dotline', '', 2);
                } else {
                    drawLine(left, top, 1, colorClass, '', '', 2);
                }
            }
            else {
                //pointCount点的数量
                for (var j = 0; j < pointCount; j++) {
                    left = left + (1.0 / pointCount);//已经累加了
                    var top = p1.y + dwspace * i + ((dwspace / pointCount) * j);
                    drawLine(left, top, 1, colorClass, '', '', 2);
                }
            }
        }
    }

    //伪造title
    function drawFalsifyTitle(left, top, title) {
        if (!!title) {
            var html = '<div style="position:absolute;width:14px;height:14px;z-index:1;left:' + (left - 7) + 'px;top:' + (top - 7) + 'px;';
            html += '"';
            html += ' title="' + title + '"';
            html += '>';
            html += '</div>';
            $(html).appendTo($board);
        }
    }

	function fillPatBaseInfo(patInfo) {

		$('.lblXm').html(patInfo.xm);
        $('.lblBlh').html(patInfo.blh);
        $('.lblZyh').html(patInfo.zyh);
        $('.lblBq').html(patInfo.bqmc);
        $('.lblCw').html(patInfo.cwmc);
        //$('#lblRyrq').html(patInfo.ryrq.substring(0,10));
        if (patInfo.ryrq != null) {
            $('.lblRqrq').html(patInfo.ryrq.substring(0, 10));
        }

        if (patInfo.cqrq != null) {
            $('.lblCqrq').html(patInfo.cqrq.substring(0, 10));
        }
    }

</script>
<script>
    //全局变量
    var canvasAble = false;
    //只调用一次即可
    function checkCanvasAble() {
        try {
            var myCanvas = document.getElementById("drawCanvas" + billIndex);
            if (myCanvas == null) {
                return;
            }
            var context = myCanvas.getContext("2d");
            canvasAble = true;
        }
        catch (eeerree) {
        }
    }

    //canvas两点画连线 p2.x 比 p1.x大
    function canvasdrawLigature(p1, p2, colorClass, type) {//增加type参数,为dotline时画虚线
        if (!canvasAble) {
            return false;
        }
        var myCanvas = document.getElementById("drawCanvas" + billIndex);
        var context = myCanvas.getContext("2d");
        var clr = colorClass.substring(1);
        if (clr % 1 == 0) {
            clr = '#' + clr;    //#333 666之类的
        }
        if (type == 'dotline') {//画虚线
            context.setLineDash([2, 3]);
        }
        context.strokeStyle = clr;//线条颜色
        context.lineWidth = 1;//设置线宽
        context.beginPath();
        context.moveTo(p1.x, p1.y);
        context.lineTo(p2.x, p2.y);
        context.stroke();//画线框
        return true;
    }

    //canvas以(left, top)为中心画一个下箭头
    function canvasdrawDownarrow(left, top, colorClass) {
        top -= 2;   //使箭头在线上
        //left - 1是因为length 2
        if (!canvasAble) {
            return false;
        }
        var myCanvas = document.getElementById("drawCanvas" + billIndex);
        var context = myCanvas.getContext("2d");
        var clr = colorClass.substring(1);
        if (clr % 1 == 0) {
            clr = '#' + clr;    //#333 666之类的
        }
        context.strokeStyle = clr;//线条颜色
        context.lineWidth = 2;//设置线宽
        context.beginPath();
        context.moveTo(left + 4 + 1, top - 2 - 1);
        context.lineTo(left, top + 2);
        context.lineTo(left - 4 - 1, top - 2 - 1);
        context.stroke();//画线框

        return true;
    }

    //canvas以(left, top)为中心画一个上箭头
    function canvasdrawUparrow(left, top, colorClass) {
        top += 2;   //使箭头在线上
        if (!canvasAble) {
            return false;
        }
        var myCanvas = document.getElementById("drawCanvas" + billIndex);
        var context = myCanvas.getContext("2d");
        var clr = colorClass.substring(1);
        if (clr % 1 == 0) {
            clr = '#' + clr;    //#333 666之类的
        }
        context.strokeStyle = clr;//线条颜色
        context.lineWidth = 2;//设置线宽
        context.beginPath();
        context.moveTo(left + 4 + 1, top + 2 + 1);
        context.lineTo(left, top - 2);
        context.lineTo(left - 4 - 1, top + 2 + 1);
        context.stroke();//画线框

        return true;
    }

    //canvas以(left, top)为中心画一个X
    function canvasdrawX(left, top, colorClass) {
        if (!canvasAble) {
            return false;
        }
        var myCanvas = document.getElementById("drawCanvas" + billIndex);
        var context = myCanvas.getContext("2d");
        var clr = colorClass.substring(1);
        if (clr % 1 == 0) {
            clr = '#' + clr;    //#333 666之类的
        }
        context.strokeStyle = clr;//线条颜色
        context.lineWidth = 2;//设置线宽
        context.beginPath();
        context.moveTo(left - 3, top + 3);
        context.lineTo(left + 3, top - 3);
        context.moveTo(left + 3, top + 3);
        context.lineTo(left - 3, top - 3);
        context.stroke();//画线框

        return true;
    }

    //canvas以(left, top)为中心画一个Square
    function canvasdrawSquare(left, top, colorClass) {
        if (!canvasAble) {
            return false;
        }
        var myCanvas = document.getElementById("drawCanvas" + billIndex);
        var context = myCanvas.getContext("2d");
        var clr = colorClass.substring(1);
        if (clr % 1 == 0) {
            clr = '#' + clr;    //#333 666之类的
        }
        context.strokeStyle = clr;//线条颜色
        context.lineWidth = 2;//设置线宽
        context.beginPath();
        context.moveTo(left - 3, top - 3);
        context.lineTo(left + 3, top - 3);
        context.lineTo(left + 3, top + 3);
        context.lineTo(left - 3, top + 3);
        //context.lineTo(left - 3, top - 3);
        context.closePath();
        context.stroke();//画线框

        return true;
    }

    //获取rq在rqCellValueArr中index
    function getIndexOfRq(rq) {
        rq = $.getDate({ date: rq, ute: true });
        for (var iiIndex = 0; iiIndex < rqCellValueArr.length; iiIndex++) {
            if (rq == rqCellValueArr[iiIndex]) {
                return iiIndex;
            }
        }
        return -1;
    }

</script>
